package com.crm.dao.permission;

import java.util.List;

import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import com.crm.pojo.Menubar;

public interface MenubarDAO extends CrudRepository<Menubar, Long> {

	@Query("from Menubar m order by m.id asc ")
	public List<Menubar> queryAll(Pageable pageable);
	
	@Query("from Menubar m where m.mname = ?1 ")
	public Menubar queryOne(String mname);
	
	@Query(nativeQuery = true,value=" SELECT MID,MNAME,"
			+ " (case WHEN MID in (SELECT MID FROM ROLE_MENUBER WHERE RID = ?1) "
			+ " THEN 1 else 0 END)  selected FROM MENUBAR ")
	public List<Object[]> queryForRoleGrantMenubar(Long id);
}
